package oneD.dynamics;

import static org.junit.Assert.*;
import junit.framework.Assert;

import org.junit.Test;

public class LagrangeTest {

	@Test
	public void testGetN() {
		int p = 1;
		Lagrange L = new Lagrange(1);
		Assert.assertEquals(L.getN(0, -1), 1.0);
		Assert.assertEquals(L.getN(0, 0), 0.5);
		Assert.assertEquals(L.getN(0, 1), 0.0);
	}

	@Test
	public void testGetdNdxi() {
		int p = 3;
		Lagrange L = new Lagrange(p);
		System.out.println(L.getdNdxi(0, 0.3));
		for (int i = 0; i < p + 1; i++)
			System.out.print(L.getdNdxi(0, -1 + (2.0 / p) * i) + " ");
		Assert.assertEquals(L.getdNdxi(0, -1), -0.5);
		Assert.assertEquals(L.getdNdxi(0, 0), -0.5);
		Assert.assertEquals(L.getdNdxi(0, 1), -0.5);
	}

	@Test
	public void testGetI() {
		int p = 7;
		Lagrange L = new Lagrange(p);
		for (int i = 0; i < p + 1; i++) {
			for (int j = 0; j < p + 1; j++)
				System.out.print(L.getI(i, j) + " ");
			System.out.println();
		}
		// Assert.assertEquals(L.getI(0, 0), )
	}
	
	@Test
	public void testGetIt() {
		int p = 7;
		Lagrange L = new Lagrange(p);
		for (int i = 0; i < p + 1; i++) {
			for (int j = 0; j < p + 1; j++)
				System.out.print(L.getIt(i, j) + " ");
			System.out.println();
		}
		// Assert.assertEquals(L.getI(0, 0), )
	}
}
